package com.yc.mqtt.handler.message;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.mqtt.MqttFixedHeader;
import io.netty.handler.codec.mqtt.MqttMessage;
import io.netty.handler.codec.mqtt.MqttMessageType;
import io.netty.handler.codec.mqtt.MqttQoS;

public class MqttPingReqMessageHandler extends MqttBaseMessageHandler{
    @Override
    public void onMessage(ChannelHandlerContext channelHandlerContext, MqttMessage mqttMessage) {
        System.out.println("收到来自：【" + channelHandlerContext.channel().remoteAddress().toString() + "】心跳");
        MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PINGRESP, false, MqttQoS.AT_MOST_ONCE, false, 0);
        channelHandlerContext.channel().writeAndFlush(fixedHeader);
    }
}
